package com.ruoyi.web.controller.wlsggk;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.waterdrop.wlsggk.pojo.WlsggkEmp;
import com.waterdrop.wlsggk.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;

/**
 * 员工信息操作处理
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/wlsggk/emp")
public class EmpController extends BaseController {

    @Autowired
    private EmpService wlsggkMaterialService;

    /**
     * 获取员工列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WlsggkEmp Wlsggkemp) {
        startPage();
        List<WlsggkEmp> list = wlsggkMaterialService.selectWlsggkEmpList(Wlsggkemp);
        return getDataTable(list);
    }

    /**
     * 导出功能
     *
     * @param response
     * @param post
     */
/*    @Log(title = "员工管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GkEmp post) {
        List<GkEmp> list = gkempService.selectGkEmpList(post);
        ExcelUtil<GkEmp> util = new ExcelUtil<GkEmp>(GkEmp.class);
        util.exportExcel(response, list, "员工数据");
    }*/

    /**
     * 根据员工id查询
     */
    @GetMapping(value = "getEmpById/{id}")
    public AjaxResult getInfo(@PathVariable Long id) {
        return success(wlsggkMaterialService.selectWlsggkEmpById(id));
    }

    /**
     * 新增员工
     */
    @Log(title = "员工管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody WlsggkEmp Wlsggkemp) {
        return toAjax(wlsggkMaterialService.insertWlsggkEmp(Wlsggkemp));
    }

    /**
     * 修改员工
     */
    @Log(title = "员工管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody WlsggkEmp Wlsggkemp) {
        return toAjax(wlsggkMaterialService.updateWlsggkEmp(Wlsggkemp));
    }

    /**
     * 删除员工
     */
    @Log(title = "员工管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(wlsggkMaterialService.deleteWlsggkEmpByIds(ids));
    }

}

